//package com.ruoyi.cms.websocket_stomp;
//
//import org.springframework.core.Ordered;
//import org.springframework.core.annotation.Order;
//import org.springframework.messaging.Message;
//import org.springframework.messaging.MessageChannel;
//import org.springframework.messaging.simp.stomp.StompCommand;
//import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
//import org.springframework.messaging.support.ChannelInterceptor;
//import org.springframework.messaging.support.MessageHeaderAccessor;
//import org.springframework.stereotype.Component;
//
///**
// * 用于控制登陆的通道拦截器
// * @author dfg
// * @date 2023-05-05 22:40
// */
//@Component
//@Order(Ordered.HIGHEST_PRECEDENCE + 99)
//public class AuthChannelInterceptor implements ChannelInterceptor {
//    @Override
//    public Message<?> preSend(Message<?> message, MessageChannel channel) {
//        StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
//        if (accessor == null) {
//            return message;
//        }
//
//        if (StompCommand.CONNECT.equals(accessor.getCommand())) {
//            // todo 做登陆拦截控制
//            accessor.setUser(new LoginUser(accessor.getSessionId()));
//        }
//        return message;
//    }
//}
//
///**
// * 自定义的用户认证类
// * @author dfg
// * @date 2023-05-05 22:48
// */
